import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
///网络请求拦截器
class ApiInterceptor extends InterceptorsWrapper {

  @override
  void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
    if (options.queryParameters.isNotEmpty) {
      debugPrint("request--get-->${options.baseUrl + options.path} \n ${options.queryParameters.toString()}");
    }
    if (options.data != null) {
      debugPrint("request--post-->${options.baseUrl + options.path} \n ${options.data.toString()}");
    }
    super.onRequest(options, handler);
  }

  @override
  void onError(DioError err, ErrorInterceptorHandler handler) {
    super.onError(err, handler);
  }

  @override
  void onResponse(Response response, ResponseInterceptorHandler handler) {
      var statusCode = response.statusCode;
      debugPrint("response---->${"statusCode= " + statusCode.toString() + " "}  ${response.data}");
      handler.next(response);
  }
}